home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2993 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.8 KB  |  63 lines

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: HELP! How do I write to a file using Symantec C++?
  5. Date: 21 Jan 1996 10:33:00 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4dt4os$5gt@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe10.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Jan 21, 1996 04:56:29 in article <HELP! How do I write to a file using
  15. Symantec C++?>, 'rajm@tiac.net (rajm)' wrote: 
  16.  
  17.  
  18. >Hi, I am a beginer at c++, and I really need some help. 
  19. >This is a silly question, but I can't find it in any book. 
  20. Yes it is since the answer is probably in every book about 
  21. programming in C/C++. 
  22.  
  23. >I am trying to create a new file, and write some data to it, line by 
  24. >line, as the computer asks questions of the user, like "what is your 
  25. >name?", etc. I do not want to use a dialog box or anything like that. 
  26. >I am jus trying to create a program in Symantec C++ 7.0.6 for the Mac 
  27. >that can create a text file with responses in it. I do not know what 
  28. >libraries I need nor do I know what commands are used. I REALLY need 
  29. >help on this, so any you could give me would be GREATLY appreciated. 
  30. >I'd be willing to do just about ANYTHING for a solution here....thanks 
  31. >in advance..... 
  32.  
  33. Try this, them modify to your needs. 
  34.  
  35. #include <iostream.h> 
  36. #include <fstream.h> 
  37.  
  38. int main () 
  39.  { 
  40.    fstream outf("test.dat", ios::out ); 
  41.    cout << "Enter text lines:\n" 
  42.            "(Control-Z, followed by <Enter>, ends)" << endl; 
  43.    char line[128]; 
  44.    while(cin.getline(line, 128)) 
  45.       outf << line << endl; 
  46.    return 0; 
  47.  } 
  48.  
  49.  
  50. >Please reply here or mail me: rajm@tiac.net 
  51. >thanks again! 
  52. -- 
  53. Pete Grant 
  54. Kalevi, Inc. 
  55. Object Oriented Software Development
  56.